<!-- box menu -->
<?php $this->renderPartial("application.views.layouts._menu");?>
<!-- End box menu -->
<?php 
    $ryear = isset($year)?$year:date("Y");
    $rmonth = isset($month)?$month:date("m");
?>

<div class="about">
        <?php $this->widget("BoxLogin");?>
        <h1><a><img src="<?php echo Yii::app()->params['static_url'];?>images/tenweb-icon-doanh-thu.png" alt="" class="kc_TB_td" /></a><a href="#" class="xanhdam">Doanh Thu</a>
        </h1>
      <div class="DT">
            <form action="<?php echo  Url::createUrl('revenue/monthYear')?>" method="post">
            Tháng
             <select name="month" style="width:10%" class="mag-btt10">
                    <option value="1" class="w99" <?php echo $rmonth ==1?"selected='true'":"" ?>>1</option>
                    <option value="2" class="w99" <?php echo $rmonth ==2?"selected='true'":"" ?>>2</option>
                    <option value="3" class="w99" <?php echo $rmonth ==3?"selected='true'":"" ?>>3</option>
                    <option value="4" class="w99" <?php echo $rmonth ==4?"selected='true'":"" ?>>4</option>
                    <option value="5" class="w99" <?php echo $rmonth ==5?"selected='true'":"" ?>>5</option>
                    <option value="6" class="w99" <?php echo $rmonth ==6?"selected='true'":"" ?>>6</option>
                    <option value="7" class="w99" <?php echo $rmonth ==7?"selected='true'":"" ?>>7</option>
                    <option value="8" class="w99" <?php echo $rmonth ==8?"selected='true'":"" ?>>8</option>
                    <option value="9" class="w99" <?php echo $rmonth ==9?"selected='true'":"" ?>>9</option>
                    <option value="10" class="w99" <?php echo $rmonth ==10?"selected='true'":"" ?>>10</option>
                    <option value="11" class="w99" <?php echo $rmonth ==11?"selected='true'":"" ?>>11</option>
                    <option value="12" class="w99" <?php echo $rmonth ==12?"selected='true'":"" ?>>12</option>
             </select>
            &nbsp;Năm
             <select name="year" style="width:10%" class="mag-btt10">
             <?php
               $i=  date("Y"); 
               while($i>=2013)  
               {
?>
                 <option value="<?php echo $i ?>" class="w99"><?php echo $i ?></option>    
<?php                
               $i--;
               }
?>
             </select>
             
             <input type="submit" value="Thống kê" class="button_DT"/>
           <br />    </form>   
            <div class="DT_1">Lựa chọn nhanh: 
                <a href="<?php echo Url::createUrl("revenue/index")?>" class="chu_DT">Hôm nay</a>&nbsp;  
                <a href="<?php echo Url::createUrl("revenue/yesterday")?>" class="chu_DT">Hôm qua</a>&nbsp;       
                <a href="<?php echo Url::createUrl("revenue/month")?>" class="chu_DT">Tháng này</a>&nbsp; 
                <a href="<?php echo Url::createUrl("revenue/preMonth")?>" class="chu_DT">Tháng trước</a>&nbsp;
            </div>
            <div class="DT_2">
                <strong class="xanhdam">Chi Tiết Doanh Thu</strong><br />
                <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#dadcda">
                  <tr class="bg_DT_tr_1">
                    <td width="10%" align="center"><Strong>STT</Strong></td>
                    <td width="10%" align="center"><Strong>Nội dung</Strong></td>
                    <td width="30%" align="center"><Strong>MO</Strong></td>
                    <td width="10%" align="center"><Strong>Đầu số</Strong></td>
                    <td width="10%" align="center"><Strong>Nhà mạng</Strong></td>
                    <td width="10%" align="center"><Strong>Hệ ĐH</Strong></td>
                    <td width="20%" align="center"><Strong>Doanh Thu</Strong></td>
                  </tr>
                <?php
                    foreach($sms as $value){
                 ?>                  
                  <tr class="bg_DT_tr_2">
                    <td width="5%" class="DT_a">1</td>
                    <td class="DT_b"><?php echo empty($value["title"])?"Không tồn tại":$value["title"]?></td>
                    <td class="DT_a"><?php echo empty($value["mo"])?"Không tồn tại":$value["mo"]?></td>
                    <td class="DT_a"><?php echo empty($value["serviceNumber"])?"Không tồn tại":$value["serviceNumber"]?></td>
                    <td class="DT_a">
                    <?php 
                        switch ($value['telco']){
                            case 1: echo "Viettel";break;
                            case 2: echo "Mobifone";break;
                            case 3: echo "Vinaphone";break;
                            case 4: echo "Vnmobi";break;
                            case 5: echo "Beeline";break;
                        } 
                    ?>
                    </td>
                    <td class="DT_a">
                    <?php switch($value['os_type']){
                        case 0: echo "";break;
                        case 1: echo "Java";break;
                        case 2: echo "Android";break;
                        case 3: echo "Ios";break;
                        case 4: echo "BlackBerry";break;
                    } ?>
                    </td>
                    <td class="DT_b"><?php echo Common::format_price(round($value["wapmaster"]));?></td>
                  </tr>
                <?php
                    }
                 ?>  
                </table>    
            </div>
      </div>    
      <!-- box footer -->
           <?php $this->widget("BoxFooter");?>
      <!-- end box footer -->
</div>

<?php

function getArrayRevenueByType($rowsRevenue,$type_value){
   $rowGame  = null;
   $i = 0;
   while($i<count($rowsRevenue))
   {
       foreach($rowsRevenue[$i] as $key=>$value){
           if(intval($value)==$type_value&&$key=="type")
           {
                $rowGame = $rowsRevenue[$i] ;
                break;
           }
       }
        $i++;
   } 
   return $rowGame;
}
    
?>